package cn.caplike.demo.repository.java;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Description:
 *
 * @author LiKe
 * @version 1.0.0
 * @date 2022-02-23 12:07
 */
public class PatternTest {
    // 按指定模式在字符串查找
    private static final String INPUT = "cbh_cac*he:\\*abc*";

    private static final char[] WILDCARD_CHARS = {'*', '?', '[', ']'};

    public static void main(String[] args) throws Exception {
        String include = "(\\*)";
        final String filted = INPUT.replaceAll("(\\\\\\*)", "");

        // 创建 Pattern 对象
        Pattern r = Pattern.compile(include);

        // 现在创建 matcher 对象
        Matcher m = r.matcher(filted);
        while (m.find()) {
            for (int idx = 0; idx < m.groupCount(); idx++) {
                System.out.println("Found value: " + m.group(idx));
            }
        }
    }

}
